﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="BindingLists.aspx.cs" Inherits="Lessons_BindingLists" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="../Style/LessonsStyle.css" rel="stylesheet" type="text/css" />
    Съдържание<br />
    <ul>
        <li>Complex Binding</li>
        <li>Доспът до текуш айтъм</li>
        <li>Използване на до current item</li>
        <li>Използване на DisplayMemberPath и ValueMemberPath</li>
        <li>Сортиране филтриране групиране на елементи в колекций</li>
        <li>Data source providers</li>
        <li>Hierarichical binding</li>
    </ul>
    <div>
        <p>
            Complex Binding</p>
        <p><span>
            Когато се използва този тип binding разработчика получава доста голяма гъвкавост.
            Bind-ването на list datasource е почти въщото като и bind-инга за един обект.
       
            </span>
            <table border=1><tbody><tr><td><div class=Code>
            &lt;Window x:Class=&quot;ComplexBinding.ComplexBindingWindow&quot;<br />
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br />
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br />
    Title=&quot;Complex Binding&quot; Height=&quot;300&quot; Width=&quot;300&quot;<br />
    xmlns:local=&quot;clr-namespace:ComplexBinding&quot;&gt;<br />
    <br />
    <br />
    &lt;Window.Resources&gt;<br />
        &lt;local:People x:Key=&quot;Family&quot;&gt;<br />
            &lt;local:Person Name=&quot;Ivan&quot; Age=&quot;12&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Petkan&quot; Age=&quot;11&quot; /&gt;<br />
            &lt;local:Person Name=&quot;Baba Meca&quot; Age=&quot;38&quot; /&gt;<br />
        &lt;/local:People&gt;<br />
        &lt;local:AgeToForegroundConverter x:Key=&quot;ageConverter&quot; /&gt;<br />
    &lt;/Window.Resources&gt;<br />
    <br />
    <br />
    &lt;Grid Name=&quot;grid&quot; Height=&quot;219&quot; Width=&quot;178&quot; DataContext=&quot;{StaticResource Family}&quot;  &gt;<br />
        &lt;TextBlock Height=&quot;22&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;44&quot; Margin=&quot;0,37,0,0&quot;&gt;Name:&lt;/TextBlock&gt;<br />
        &lt;TextBox Text=&quot;{Binding Path=Name}&quot; Margin=&quot;44,37,15,0&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Top&quot; /&gt;<br />
        &lt;TextBlock Margin=&quot;0,78,0,0&quot; Height=&quot;35&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;38&quot;&gt;Age:&lt;/TextBlock&gt;<br />
        &lt;TextBox Name=&quot;ageTextBox&quot; Text=&quot;{Binding Path=Age}&quot; Foreground=&quot;{Binding Path=Age ,Converter={StaticResource ageConverter}}&quot;  Margin=&quot;44,78,15,0&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Top&quot; /&gt;<br />
        &lt;Button Click=&quot;birthdayButton_Click&quot; Foreground=&quot;{Binding Path=Foreground, ElementName=ageTextBox}&quot;<br />
                Name=&quot;birthdayButton&quot; Margin=&quot;44,0,15,48&quot; Height=&quot;41&quot; VerticalAlignment=&quot;Bottom&quot;&gt;Birthday&lt;/Button&gt;<br />
    &lt;/Grid&gt;<br />
<br />
    <br />
&lt;/Window&gt;
            </div></td></tr></tbody></table>
        </p>
    </div>
    <div>
        <p>
            Доспът до текуш айтъм</p>
        <p>
            <span>Пропъртитата на TextBox могат да бъдат bind-нати само към един обект. По този
                начин bind-га им даваточно определен елемент от обекта. По default винаги първия
                елемент се инициализа като текущ. Чрез collecation view се извършва посредничество
                между контола и елементите в колекцията. Основната работа е да предоставя основни
                опрерации като Sorting, Filtering, Grouping.</span>
               <table border=1><tbody><tr><td> <div class=Code>
                <pre>
                namespace NavigatingBetweenItems
{
    /// <summary>
    /// Interaction logic for NavigatingWindow.xaml
    /// </summary>
    public partial class NavigatingWindow : Window
    {
        public NavigatingWindow()
        {
            InitializeComponent();
        }

        ICollectionView GetFamilyView()
        {
            People people = (People)this.FindResource("Family");
            return CollectionViewSource.GetDefaultView(people);
        }

        private void birthdayButton_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            Person person = (Person)view.CurrentItem;
            ++person.Age;
            MessageBox.Show(string.Format("Happy Birthday, {0}, age {1}!", person.Name,person.Age),"Birthday");
        }

        private void buttonBack_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToPrevious();
            if (view.IsCurrentBeforeFirst)
            {
                view.MoveCurrentToFirst();
            }
        }

        private void buttonForward_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToNext();
            if (view.IsCurrentAfterLast)
            {
                view.MoveCurrentToLast();
            }
        }
    }

    public class AgeToForegroundConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            if (targetType != typeof(Brush))
            { 
                return null;
            }
            int age = int.Parse(value.ToString());
            return (age >= 25 ? Brushes.Red : Brushes.Black);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    class Person:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void Notify(string propName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
        string name;
        public string Name
        {
            get { return this.name; }
            set
            {
                if (this.name == value) { return; }
                this.name = value;
                Notify("Name");
            }
        }
        int age;
        public int Age
        {
            get { return this.age; }
            set
            {
                if (this.age == value) { return; }
                this.age = value;
                Notify("Age");
            }
        }

        public Person() { }
        public Person(string name, int age)
        {
            this.name = name;
            this.age = age;
        }
    }

    class People : List<Person> { }
}
                </pre>
                </div></td></tr></tbody></table>
        </p>
    </div>
    <div>
        <p>
            Използване на DisplayMemberPath и ValueMemberPath
        </p>
        <p>
            <span>DisplayMemberPath- може да го използвате ако искате да покжете всички обекти на
                един клас в едно пропърти.</span>
                <table border=1><tbody><tr><td><div class=Code>
                &lt;Window x:Class=&quot;DisplayMemberPath.PathWindow&quot;<br />
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br />
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br />
    Title=&quot;DisplayMemberPath and ValueMemberPath &quot; Height=&quot;386&quot; Width=&quot;396&quot; <br />
        xmlns:local=&quot;clr-namespace:DisplayMemberPath&quot;&gt;<br />
    <br />
    <br />
    &lt;Window.Resources&gt;<br />
        &lt;local:People x:Key=&quot;Family&quot;&gt;<br />
            &lt;local:Person Name=&quot;Ivancho&quot; Age=&quot;11&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Hasancho&quot; Age=&quot;12&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Marusq&quot; Age=&quot;38&quot;/&gt;<br />
        &lt;/local:People&gt;<br />
        &lt;local:AgeToForegroundConverter<br />
      x:Key=&quot;ageConverter&quot; /&gt;<br />
    &lt;/Window.Resources&gt;<br />
    <br />
    <br />
    &lt;Grid Name=&quot;grid&quot; Height=&quot;351&quot; Width=&quot;364&quot; DataContext=&quot;{StaticResource Family}&quot;&gt;<br />
        &lt;TextBlock Height=&quot;22&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;44&quot; Margin=&quot;0,138,0,0&quot;&gt;Name:&lt;/TextBlock&gt;<br />
        &lt;TextBox Text=&quot;{Binding Path=Name}&quot; Margin=&quot;44,135,15,0&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Top&quot; /&gt;<br />
        &lt;TextBlock Margin=&quot;0,0,0,149&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;38&quot; Height=&quot;22&quot; VerticalAlignment=&quot;Bottom&quot;&gt;Age:&lt;/TextBlock&gt;<br />
        &lt;TextBox Name=&quot;ageTextBox&quot; Text=&quot;{Binding Path=Age}&quot; Foreground=&quot;{Binding Path=Age ,Converter={StaticResource ageConverter}}&quot;  Margin=&quot;44,0,15,149&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Bottom&quot; /&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Foreground=&quot;{Binding Path=Foreground, ElementName=ageTextBox}&quot; Click=&quot;birthdayButton_Click&quot;<br />
                Name=&quot;birthdayButton&quot; Margin=&quot;44,0,15,90&quot; Height=&quot;41&quot; VerticalAlignment=&quot;Bottom&quot;&gt;Birthday&lt;/Button&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Click=&quot;buttonBack_Click&quot; Height=&quot;35&quot; Margin=&quot;44,0,0,26&quot; Name=&quot;buttonBack&quot; VerticalAlignment=&quot;Bottom&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;96&quot;&gt;&amp;lt;&lt;/Button&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Click=&quot;buttonForward_Click&quot; Height=&quot;35&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,0,15,26&quot; Name=&quot;buttonForward&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;102&quot;&gt;&amp;gt;&lt;/Button&gt;<br />
        &lt;ListBox MouseDoubleClick=&quot;lb_MouseDoubleClick&quot; Height=&quot;59&quot; Margin=&quot;44,42,15,0&quot; Name=&quot;lb&quot; VerticalAlignment=&quot;Top&quot; ItemsSource=&quot;{Binding}&quot; DisplayMemberPath=&quot;Name&quot; SelectedValuePath=&quot;Age&quot; IsSynchronizedWithCurrentItem=&quot;True&quot;/&gt;<br />
    &lt;/Grid&gt;<br />
    <br />
    <br />
&lt;/Window&gt;<br />

                </div></td></tr></tbody></table>
        </p>
        <p>
            <span>ValueMemberPath- класът ItemsContols предоставя път до описанието на избраната
                стойност. Също така данни които често се използват когато се избират или се проментя
                елемент.</span>
                  <table border=1><tbody><tr><td><div class=Code>
                <pre>
                namespace ValueMemberPath
{
    /// <summary>
    /// Interaction logic for PathWindow.xaml
    /// </summary>
    public partial class PathWindow : Window
    {
        public PathWindow()
        {
            InitializeComponent();
        }

        ICollectionView GetFamilyView()
        {
            People people = (People)this.FindResource("Family");
            return CollectionViewSource.GetDefaultView(people);
        }

        private void birthdayButton_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            Person person = (Person)view.CurrentItem;
            ++person.Age;
            MessageBox.Show(string.Format("Happy Birthday, {0}, age {1}!", person.Name, person.Age), "Birthday");
        }

        private void buttonBack_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToPrevious();
            if (view.IsCurrentBeforeFirst)
            {
                view.MoveCurrentToFirst();
            }
        }

        private void buttonForward_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToNext();
            if (view.IsCurrentAfterLast)
            {
                view.MoveCurrentToLast();
            }
        }

        private void lb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            int index = lb.SelectedIndex;
            if (index < 0) { return; }
            Person item = (Person)lb.SelectedItem;
            int value = (int)lb.SelectedValue;
            MessageBox.Show(string.Format("Name:  {0}, Age:  {1}!", item.Name, value));
        }
    }

    public class AgeToForegroundConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            if (targetType != typeof(Brush)) 
            { 
                return null;
            }
            int age = int.Parse(value.ToString());
            return (age >= 25 ? Brushes.Red : Brushes.Black);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    class Person:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void Notify(string propName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
        string name;
        public string Name
        {
            get { return this.name; }
            set
            {
                if (this.name == value) { return; }
                this.name = value;
                Notify("Name");
            }
        }
        int age;
        public int Age
        {
            get { return this.age; }
            set
            {
                if (this.age == value) { return; }
                this.age = value;
                Notify("Age");
            }
        }
        public Person() { }
        public Person(string name, int age)
        {
            this.name = name;
            this.age = age;
        }

    }

    class People : List<Person> { }
}
                </pre>
                </div></td></tr></tbody></table>
                </p>
    </div>
    <div>
        <p>
            Сортиране филтриране групиране на елементи в колекций
        </p>
        <p>
        <span>
            Сортиране- позвовява да се представи инвормацията сортирана по определ критериий.
            Доста лесен начин да се сортира инфомацията е чрез манипулиртанто на SoetDescriprions
            пропъртито. Освен това може да се предостави изглед чрез импрементирането на интерфеиса
            IComparer.<table border=1><tbody><tr><td><div class=Code>
                <pre>
                
                namespace Sorting
{
    /// <summary>
    /// Interaction logic for SortingWindow.xaml
    /// </summary>
    public partial class SortingWindow : Window
    {
        public SortingWindow()
        {
            InitializeComponent();
        }

        ICollectionView GetFamilyView()
        {
            People people = (People)this.FindResource("Family");
            return CollectionViewSource.GetDefaultView(people);
        }


        private void birthdayButton_Click(object sender, RoutedEventArgs e)
        {
            People people = (People)this.FindResource("Family");
            ICollectionView view =
              CollectionViewSource.GetDefaultView(people);
            Person person = (Person)view.CurrentItem;
            ++person.Age;
            MessageBox.Show(string.Format("Happy Birthday, {0}, age {1}!", person.Name, person.Age), "Birthday");
        }

        private void buttonBack_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToPrevious();
            if (view.IsCurrentBeforeFirst)
            {
                view.MoveCurrentToFirst();
            }
        }

        private void buttonForward_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            view.MoveCurrentToNext();
            if (view.IsCurrentAfterLast)
            {
                view.MoveCurrentToLast();
            }
        }

        private void lb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            int index = lb.SelectedIndex;
            if (index < 0) { return; }
            Person item = (Person)lb.SelectedItem;
            int value = (int)lb.SelectedValue;
            MessageBox.Show(string.Format("Name:  {0}, Age:  {1}!", item.Name, value));
        }

        private void buttonSort_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = GetFamilyView();
            if (view.SortDescriptions.Count == 0)
            {
                view.SortDescriptions.Add(
                  new SortDescription("Name", ListSortDirection.Ascending));
                view.SortDescriptions.Add(
                  new SortDescription("Age", ListSortDirection.Descending));
            }
            else
            {
                view.SortDescriptions.Clear();
            }
        }
    }

    public class AgeToForegroundConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            if (targetType != typeof(Brush))
            {
                return null;
            }
            int age = int.Parse(value.ToString());
            return (age >= 25 ? Brushes.Red : Brushes.Black);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    class Person:INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void Notify(string propName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
        string name;
        public string Name
        {
            get { return this.name; }
            set
            {
                if (this.name == value) { return; }
                this.name = value;
                Notify("Name");
            }
        }
        int age;
        public int Age
        {
            get { return this.age; }
            set
            {
                if (this.age == value) { return; }
                this.age = value;
                Notify("Age");
            }
        }
        public Person() { }
        public Person(string name, int age)
        {
            this.name = name;
            this.age = age;
        }
    }

    class People : List<Person> { }


    public class NamedAge : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void Notify(string propNameForAge)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propNameForAge));
            }
        }
        string nameForAge;
        public string NameForAge
        {
            get { return this.nameForAge; }
            set
            {
                if (this.nameForAge == value) { return; }
                this.nameForAge = value;
                Notify("NameForAge");
            }
        }
        int ageId;
        public int AgeId
        {
            get { return this.ageId; }
            set
            {
                if (this.ageId == value) { return; }
                this.ageId = value;
                Notify("AgeId");
            }
        }
    }

    class NamedAges : ObservableCollection<NamedAge> { }
}
                
                </pre>
                </div></td></tr></tbody></table><br />
            Филтриране- чрез тази опрация получаваме само обектите които съдържат определена
            характеристика и не се нуждаем от останалите.
            
            
            <br />
            Гръпиране - тази операция се използва да се групират елементи коитои по сходни качества.
            Чрез PropertyGroupDescription обекта чможе да се сложи име на пропътито коеот икскат
            да групирате. Също така чрез group style колекцията могат да се визуализира информация
            свързана с друга информация.<br/>
             <table border=1><tbody><tr><td><div class=Code>
             &lt;Window x:Class=&quot;Grouping.GroupingWindow&quot;<br />
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;<br />
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;<br />
    Title=&quot;Grouping&quot; Height=&quot;386&quot; Width=&quot;396&quot; <br />
          xmlns:local=&quot;clr-namespace:Grouping&quot;&gt;<br />
    &lt;Window.Resources&gt;<br />
        &lt;local:People x:Key=&quot;Family&quot;&gt;<br />
            &lt;local:Person Name=&quot;Hasancho&quot; Age=&quot;11&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Ivancho&quot; Age=&quot;12&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Bai-Mangal&quot; Age=&quot;38&quot;/&gt;<br />
            &lt;local:Person Name=&quot;Kaka Mara&quot; Age=&quot;38&quot;/&gt;<br />
        &lt;/local:People&gt;<br />
        &lt;local:NamedAges x:Key=&quot;NamedAgeLookup&quot;&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Zero&quot; AgeId=&quot;0&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;One&quot; AgeId=&quot;1&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Two&quot; AgeId=&quot;2&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Three&quot; AgeId=&quot;3&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Four&quot; AgeId=&quot;4&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Five&quot; AgeId=&quot;5&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Six&quot; AgeId=&quot;6&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Seven&quot; AgeId=&quot;7&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Eight&quot; AgeId=&quot;8&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Nine&quot; AgeId=&quot;9&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Ten&quot; AgeId=&quot;10&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Eleven&quot; AgeId=&quot;11&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Twelve&quot; AgeId=&quot;12&quot; /&gt;<br />
            &lt;local:NamedAge NameForAge=&quot;Thirteen&quot; AgeId=&quot;13&quot; /&gt;<br />
        &lt;/local:NamedAges&gt;<br />
        &lt;local:AgeToForegroundConverter<br />
      x:Key=&quot;ageConverter&quot; /&gt;<br />
    &lt;/Window.Resources&gt;<br />
    &lt;Grid Name=&quot;grid&quot; Height=&quot;351&quot; Width=&quot;364&quot; DataContext=&quot;{StaticResource Family}&quot;&gt;<br />
        &lt;TextBlock Height=&quot;22&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;44&quot; Margin=&quot;0,95,0,0&quot;&gt;Name:&lt;/TextBlock&gt;<br />
        &lt;TextBox Text=&quot;{Binding Path=Name}&quot; Margin=&quot;44,92,15,0&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Top&quot; /&gt;<br />
        &lt;TextBlock Margin=&quot;0,138,0,0&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;38&quot; Height=&quot;22&quot; VerticalAlignment=&quot;Top&quot;&gt;Age:&lt;/TextBlock&gt;<br />
        &lt;TextBox Name=&quot;ageTextBox&quot; Text=&quot;{Binding Path=Age}&quot; Foreground=&quot;{Binding Path=Age ,Converter={StaticResource ageConverter}}&quot;  Margin=&quot;44,135,15,0&quot; Height=&quot;25&quot; VerticalAlignment=&quot;Top&quot; /&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Foreground=&quot;{Binding Path=Foreground, ElementName=ageTextBox}&quot; Click=&quot;birthdayButton_Click&quot;<br />
                Name=&quot;birthdayButton&quot; Margin=&quot;44,0,15,90&quot; Height=&quot;41&quot; VerticalAlignment=&quot;Bottom&quot;&gt;Birthday&lt;/Button&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Click=&quot;buttonBack_Click&quot; Height=&quot;35&quot; Margin=&quot;44,0,0,11&quot; Name=&quot;buttonBack&quot; VerticalAlignment=&quot;Bottom&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;102&quot;&gt;&amp;lt;&lt;/Button&gt;<br />
        &lt;Button FontSize=&quot;20&quot; Click=&quot;buttonForward_Click&quot; Height=&quot;35&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,0,15,11&quot; Name=&quot;buttonForward&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;102&quot;&gt;&amp;gt;&lt;/Button&gt;<br />
        &lt;ListBox MouseDoubleClick=&quot;lb_MouseDoubleClick&quot; Height=&quot;59&quot; Margin=&quot;44,14,15,0&quot;<br />
        Name=&quot;lb&quot; VerticalAlignment=&quot;Top&quot; ItemsSource=&quot;{Binding}&quot; <br />
        SelectedValuePath=&quot;Age&quot; IsSynchronizedWithCurrentItem=&quot;True&quot; &gt;<br />
            &lt;ListBox.GroupStyle&gt;<br />
                &lt;x:Static Member=&quot;GroupStyle.Default&quot; /&gt;<br />
            &lt;/ListBox.GroupStyle&gt;<br />
            &lt;ListBox.ItemTemplate&gt;<br />
                &lt;DataTemplate&gt;<br />
                    &lt;TextBlock&gt;<br />
        &lt;TextBlock Text=&quot;{Binding Path=Name}&quot; /&gt;<br />
        (age: &lt;TextBlock<br />
          Text=&quot;{Binding Path=Age}&quot; Foreground=&quot;{Binding Path=Age, Converter={StaticResource ageConverter}}&quot; /&gt;)<br />
      &lt;/TextBlock&gt;<br />
                &lt;/DataTemplate&gt;<br />
            &lt;/ListBox.ItemTemplate&gt;<br />
        &lt;/ListBox&gt;<br />
        &lt;ComboBox ItemsSource=&quot;{Binding Source={StaticResource NamedAgeLookup}}&quot;<br />
  DisplayMemberPath=&quot;NameForAge&quot; SelectedValuePath=&quot;AgeId&quot;  SelectedValue=&quot;{Binding Path=Age}&quot; Margin=&quot;44,175.138,15,152.862&quot; Name=&quot;comboBox1&quot; /&gt;<br />
        &lt;Button Click=&quot;buttonSort_Click&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;44,0,0,56&quot; Name=&quot;buttonSort&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;75&quot;&gt;Sort&lt;/Button&gt;<br />
        &lt;Button Click=&quot;buttonFilter_Click&quot; Height=&quot;23&quot; Margin=&quot;159,0,0,56&quot; Name=&quot;buttonFilter&quot; VerticalAlignment=&quot;Bottom&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;75&quot;&gt;Filter&lt;/Button&gt;<br />
        &lt;Button Click=&quot;buttonGrouping_Click&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,0,15,56&quot; Name=&quot;buttonGrouping&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;75&quot;&gt;Grouping&lt;/Button&gt;<br />
    &lt;/Grid&gt;<br />
&lt;/Window&gt;<br />

                </div></td></tr></tbody></table></span>
              
        </p>
    </div>
    <div>
        <p>
            Data source providers
        </p>
        <p><span>
            WPF работи с два основни типа доставчици на информация<br />
            ObjectDataProvider - позволяв да се подават източници на данни като например класове,
            обекти. Освен това позлволява да се подават и по-сложни структури като инвормация
            която има релация помежду си.
            <br />
            XmlDataProvider - се използва XmlDocument и XmlElement за обновяване или достъпване
            на някоя стойност се използват XmlElemtnt и SetAttribute методите. Ако искате да
            се сортира или групира описанието или да се добави нов елемент се изпозват XPathExpressions
            <br />
            И двата наследяват klasa DataSourceProvider</span>
              <table border=1><tbody><tr><td><div class=Code>
                
                </div></td></tr></tbody></table>
        </p>
    </div>
    <div>
        <p>
            Hierarichical binding</p>
        <p><span>
            Най общо включва доста нива на вложеност котио се изграждат runtime. Компонента
            може да се разширява като меню или дърво. WPF поддържа build-in йерархичен binding
            чрез използването на специален тип темплейт.</span>
             
        </p>
    </div>
</asp:Content>
